import 'dart:async';

import 'package:qgchat/bloc/blocProvider.dart';
import 'package:qgchat/http/apis/user.dart';
import 'package:qgchat/http/models/lovevideModel.dart';

class LovevideoBloc implements BlocBase {
  int page = 0;
  int limit = 10;
  List<LovevideoModel> list = [];

  LovevideoBloc() {
    getMake();
  }

  // ##########  DEFAULT  ##############


  // // ##########  STREAMS  ##############
    /// 喜欢stream
  StreamController _call = StreamController<List<LovevideoModel>>.broadcast();
  Sink get _callSink => _call.sink;
  Stream get callStream => _call.stream;

  void dispose(){
    _call.close();
  }

  // // ##########  HANDLING  ##############

  List<LovevideoModel> loveonemore = [];

  /// 获取预约列表数据
  void getMake() async {
    page = page + 1;
    List<LovevideoModel> result =await UserApis.lovevideo(page: page, limit: limit);
    if (result.isNotEmpty) {
      list.addAll(result);
      loveonemore = result;
      _callSink.add(list);
    }
  }

  /// 刷新预约列表
  void onRefresh() async {
    page = 0;
    list = [];
    getMake();
  }
}
